package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCompanyReportTask;
import com.ruoyi.system.service.ISysCompanyReportTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业数字化诊断任务Controller
 * 
 * @author ruoyi
 * @date 2023-06-28
 */
@Api(tags = "企业数字化诊断报告生成任务")
@RestController
@RequestMapping("/system/task")
public class SysCompanyReportTaskController extends BaseController
{
    @Autowired
    private ISysCompanyReportTaskService sysCompanyReportTaskService;

    /**
     * 查询企业数字化诊断任务列表
     */
   // @PreAuthorize("@ss.hasPermi('system:task:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询企业数字化诊断任务列表")
    public TableDataInfo list(SysCompanyReportTask sysCompanyReportTask)
    {
        startPage();
        List<SysCompanyReportTask> list = sysCompanyReportTaskService.selectSysCompanyReportTaskList(sysCompanyReportTask);
        return getDataTable(list);
    }

    /**
     * 导出企业数字化诊断任务列表
     */
   // @PreAuthorize("@ss.hasPermi('system:task:export')")
    @Log(title = "企业数字化诊断任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyReportTask sysCompanyReportTask)
    {
        List<SysCompanyReportTask> list = sysCompanyReportTaskService.selectSysCompanyReportTaskList(sysCompanyReportTask);
        ExcelUtil<SysCompanyReportTask> util = new ExcelUtil<SysCompanyReportTask>(SysCompanyReportTask.class);
        util.exportExcel(response, list, "企业数字化诊断任务数据");
    }

    /**
     * 获取企业数字化诊断任务详细信息
     */
  //  @PreAuthorize("@ss.hasPermi('system:task:query')")
    @GetMapping(value = "/{taskId}")
    @ApiOperation(value = "获取企业数字化诊断任务详细信息")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return AjaxResult.success(sysCompanyReportTaskService.selectSysCompanyReportTaskByTaskId(taskId));
    }

    /**
     * 新增企业数字化诊断任务
     */
  //  @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "企业数字化诊断任务", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增企业数字化诊断任务")
    public AjaxResult add(@RequestBody SysCompanyReportTask sysCompanyReportTask)
    {
        sysCompanyReportTask.setCreateBy(getUsername());
        return toAjax(sysCompanyReportTaskService.insertSysCompanyReportTask(sysCompanyReportTask));
    }

    /**
     * 修改企业数字化诊断任务
     */
  //  @PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "企业数字化诊断任务", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改企业数字化诊断任务")
    public AjaxResult edit(@RequestBody SysCompanyReportTask sysCompanyReportTask)
    {
        return toAjax(sysCompanyReportTaskService.updateSysCompanyReportTask(sysCompanyReportTask));
    }

    /**
     * 删除企业数字化诊断任务
     */
  //  @PreAuthorize("@ss.hasPermi('system:task:remove')")
    @Log(title = "企业数字化诊断任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    @ApiOperation(value = "删除企业数字化诊断任务")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(sysCompanyReportTaskService.deleteSysCompanyReportTaskByTaskIds(taskIds));
    }
}
